package security.msg;

public class ErrorMessage implements Message {
	public static int READ_ERROR = 1;
	public static int WRITE_ERROR = 2;
	public static int APPLY_ERROR = 3;
	public static int LIST_ERROR = 4;
	public static int READ_FORMAT_ERROR = 5;
	public static int WRITE_FORMAT_ERROR = 6;
	public static int APPLY_FORMAT_ERROR = 7;
	public static int SHOW_FORMAT_ERROR = 8;
	public static int ADD_COI_FORMAT_ERROR = 9;
	
	private int errorType = 1;
	private String content;
	
	public ErrorMessage(int errorType) {
		this.errorType = errorType;
	}
	
	@Override
	public String printMsg() {
		String str[] = content.split(" "); // Subject --> Object
		String msg = "ERROR--> ";
		if(errorType == READ_ERROR) {
			msg += str[0] + " does not have read permission on "+str[1];
		} else if(errorType == WRITE_ERROR) {
			msg += str[0] + " does not have write permission on "+str[1];
		} else if(errorType == APPLY_ERROR) {
			msg += str[0] + " can not apply for company "+str[1];
		} else if(errorType == LIST_ERROR) {
			msg += "Usage: list company|employee|contractor";
		} else if(errorType == READ_FORMAT_ERROR) {
			msg += "Usage: read subject object";
		} else if(errorType == WRITE_FORMAT_ERROR) {
			msg += "Usage: write subject object";
		} else if(errorType == APPLY_FORMAT_ERROR) {
			msg += "Usage: apply subject company";
		} else if(errorType == SHOW_FORMAT_ERROR) {
			msg += "Usage: show coiID to list all companies of a COI";
		} else if(errorType == ADD_COI_FORMAT_ERROR) {
			msg += "Usage: add coi coiID company1 company2 ...";
		}
		
		return msg;
	}
	
	@Override
	public void setContent(String str) {
		// TODO Auto-generated method stub
		content = str;
	}

}
